package com.xian.im.modules.avchat.rule;

import com.xian.im.common.model.session.SessionUser;
import com.xian.im.common.proto.MsgRequest;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: xian-code
 * @description:
 * @author: liru.xian
 * @create: 2021-01-21 16:36
 **/
@Component
public class MessageCheckRuleChain {


    private List<CheckMute> checkMutes = new ArrayList<>();

    public MessageCheckRuleChain(List<CheckMute> checkMuteList){
        checkMutes.addAll(checkMuteList);
    }

    public void addCheck(CheckMute checkMute){
        checkMutes.add(checkMute);
    }

    public void doHandler(MsgRequest message, SessionUser sessionUser){
        for (CheckMute checkMute : checkMutes) {
            checkMute.mute(message,sessionUser);
        }
    }
}
